package com.threefish;

import lombok.extern.slf4j.Slf4j;
import org.nutz.lang.Encoding;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.builder.SpringApplicationBuilder;
import org.springframework.boot.web.servlet.support.SpringBootServletInitializer;
import org.springframework.context.annotation.ImportResource;
import org.springframework.transaction.annotation.EnableTransactionManagement;
import org.springframework.web.servlet.config.annotation.EnableWebMvc;

import java.nio.charset.Charset;

/**
 * @author 黄川 huchuc@vip.qq.com
 * @date: 2018/9/6
 **/
@SpringBootApplication
@ImportResource("classpath:spring/context.xml")
@EnableWebMvc
@EnableTransactionManagement
@Slf4j
public class Application extends SpringBootServletInitializer {

    public static void main(String[] args) {
        if (!Charset.defaultCharset().name().equalsIgnoreCase(Encoding.UTF8)) {
            log.error("这个项目必须运行在UTF-8环境下, 请添加 -Dfile.encoding=UTF-8 至 JAVA_OPTS");
            throw new RuntimeException("This project must be run in UTF-8 environment, please add -Dfile.encoding=UTF-8 to JAVA_OPTS");
        } else {
            System.setProperty("spring.devtools.restart.enabled","false");
            SpringApplication.run(Application.class, args);
            System.out.printf("Ureport 报表请访问:%s \n", "http://127.0.0.1:8080/demo/ureport/designer");
            System.out.printf("首页请访问:        %s \n", "http://127.0.0.1:8080/demo/main/platform");
            System.out.printf("查看文档请访问：    %s \n", "http://127.0.0.1:8080/demo/swagger-ui.html");
        }
    }

    @Override
    protected SpringApplicationBuilder configure(SpringApplicationBuilder application) {
        return application.sources(Application.class);
    }

}
